﻿//-----------------------------------------------------------------------
// <copyright file="IMySqlConnection.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: ISlwyMySql.cs
// * history : created by qinchaoyue 2017-10-22 09:07:45
// </copyright>
//-----------------------------------------------------------------------

using System.Collections.Generic;
using System.Data;
using Slwy.MySql.Models;

namespace Slwy.MySql.Contracts
{
    /// <summary>
    /// 获取数据库连接
    /// </summary>
    public interface IMySqlConnection
    {
        /// <summary>
        /// 获取所有的连接
        /// </summary>
        /// <returns></returns>
        IList<MConnectionStrings> GetConnections();

        /// <summary>
        /// 获取读连接字符串
        /// </summary>
        /// <param name="suffix"> 库名后缀 </param>
        /// <returns>读连接字符串</returns>
        string GetReadConnectionString(string suffix = "");

        /// <summary>
        /// 获取写连接字符串
        /// </summary>
        /// <param name="suffix"> 库名后缀 </param>
        /// <returns>写连接字符串</returns>
        string GetWriteConnectionString(string suffix = "");

        /// <summary>
        /// 获取自定义连接名称的数据库连接
        /// </summary>
        /// <param name="connectionKey">数据库连接 key</param>
        /// <param name="suffix"> 库名后缀 </param>
        /// <returns>数据库连接</returns>
        IDbConnection GetCustomeConnection(string connectionKey, string suffix = "");

        /// <summary>
        /// 获取读连接
        /// </summary>
        /// <param name="suffix"> 库名后缀 </param>
        /// <returns>
        /// 数据库连接
        /// </returns
        IDbConnection GetReadConnection(string suffix = "");

        /// <summary>
        /// 获取写连接
        /// </summary>
        /// <param name="suffix"> 库名后缀 </param>
        /// <returns>
        /// 数据库连接
        /// </returns
        IDbConnection GetWriteConnection(string suffix = "");
    }
}